home *** CD-ROM | disk | FTP | other *** search
/ Netware Super Library / Netware Super Library.iso / pgm_tool / lu62 / novell / nwsndn.asm < prev    next >
Assembly Source File  |  1995-07-03  |  7KB  |  237 lines

  1. ;********************************************************
  2. ;*                                                      *
  3. ;*                    DrvSend                           *
  4. ;*                                                      *
  5. ;*   Function:   Split the input whole block into       *
  6. ;*               some packets and send its using        *
  7. ;*               IPX services.                          *
  8. ;*   Input:      SS:BP points to registers save         *
  9. ;*               area. Select from this area CX,        *
  10. ;*               and DS:DX. In CX's length of segment,  *
  11. ;*               DS:DX points start of segment.         *
  12. ;*   Output:     In AX places IPX return code or zero   *
  13. ;*               if all O.K!                            *
  14. ;*                                                      *
  15. ;*                                                      *
  16. ;* CopyRight 1995. Nicholas Poljakov all rights reserved.*
  17. ;*                                                      *
  18. ;********************************************************
  19. .MODEL TINY
  20. .DOSSEG
  21.  
  22. include c:\lu62\novell\inc\ipxhdr.inc
  23. include c:\lu62\novell\inc\seg.inc
  24.  
  25. EXTRN   ipxProc : DWORD
  26. EXTRN   CancelECB : PROC
  27. EXTRN   PrepECB : PROC
  28. EXTRN   ipxECB : BYTE
  29. EXTRN   ActLuMsg : BYTE
  30. EXTRN   LocalS : BYTE
  31.  
  32. PUBLIC  DrvSend, CurSeg, SndStart, MainCycl
  33. PUBLIC  SndExit, SndBlk, LastBlk, CallIPX, PollInUse
  34. PUBLIC  SetNtAddr, NextBlk
  35. PUBLIC  LocSnd, SndCont
  36. PUBLIC  SetSAddr, SBExit
  37. PUBLIC  InfoMsg, TestBcs, CmpCycl, SetExit
  38.  
  39. BLKLT    EQU   546      ; length of IPX max. block
  40.  
  41. .CODE
  42. DrvSend  PROC
  43.          jmp   SndStart
  44.  
  45. CurSeg   DD    0        ; pointer to current segment
  46. ipxSECB  IPXECB <>      ; IPX ECB area
  47. ipxHDR   IPXHDR <>      ; IPX header area
  48.  
  49. SndStart:
  50.          cmp   LocalS, 0 ; is it a "Local_Send" operation ?
  51.          jne   LocSnd
  52.  
  53.          les   bx, DWORD PTR [bp + 8]  ; input DS:DX pointer
  54.          mov   cx, WORD PTR [bp + 12]  ; input CX value
  55.          jmp   short SndCont
  56.  
  57. LocSnd:
  58.          mov   bx, OFFSET ActLuMsg
  59.          mov   cx, PRFLT + 9
  60.  
  61. SndCont:
  62.          mov   dx, cx
  63.          sub   dx, PRFLT
  64.          cmp   es:[bx].SegLen, dx
  65.          je    MainCycl
  66.          mov   ax, -1   ; error return code (wrong length of segment)
  67.          jmp   SndExit
  68. MainCycl:
  69.          mov   WORD PTR CurSeg, bx     ; save pointer
  70.          mov   ax, es                  ; to
  71.          mov   WORD PTR CurSeg + 2, ax ; current segment
  72.          call  SetNtAddr
  73.          and   ax, ax   ; check return code
  74.          jnz   SndExit  ; bad return code...
  75.          call  NextBlk
  76.          call  SndBlk   ; prepare IPX fields and send block
  77.          and   ax, ax
  78.          jnz   SndExit  ; bad return code fron IPX
  79.          les   bx, CurSeg
  80.          les   bx, es:[bx].SegLink     ; pointer to next segment
  81.                                        ; if it present.
  82.          mov   ax, es
  83.          and   ax, ax   ; if NULL pointer
  84.          jnz   MainCycl ; then
  85.          and   bx, bx   ; exit
  86.          jnz   MainCycl ; from procedure
  87.  
  88.          call  PrepECB  ; set "listen" mode for receiving
  89.  
  90. SndExit:
  91.          clc
  92.          ret
  93. DrvSend  ENDP
  94.  
  95. SndBlk   PROC
  96. ;*
  97. ;* On input : CX - total length of block; ES:BX - pointer to
  98. ;*            block.
  99. ;*
  100.          push  cx
  101.  
  102. ; First, sets ECB fields
  103.  
  104.          mov   ipxSECB.SocNum, MY_SOCKET
  105.          mov   ipxSECB.FragNum, 2 ; two fragments : IPX header and
  106.                                   ; data segment.
  107.  
  108.          mov   ax, OFFSET ipxHDR
  109.          mov   WORD PTR ipxSECB.FAddr, ax
  110.          mov   ax, cs
  111.          mov   WORD PTR ipxSECB.FAddr + 2, ax
  112.          mov   ipxSECB.FLt, 30 ; header length
  113.  
  114. SetSAddr:
  115.          mov   WORD PTR ipxSECB.SAddr, bx
  116.          mov   ax, es
  117.          mov   WORD PTR ipxSECB.SAddr + 2, ax
  118.          cmp   cx, BLKLT
  119.          jb    LastBlk
  120.          mov   ipxSECB.SLt, BLKLT ; header length
  121.          mov   ax, BLKLT + 30
  122.          xchg  ah, al
  123.          mov   ipxHDR.PLt, ax     ; length of IPX header and max. block
  124.                                   ; length
  125.          add   bx, BLKLT          ; pointer to next segment of message
  126.          sub   cx, BLKLT          ; rest length of message
  127.          jmp   short CallIPX
  128. LastBlk:
  129.          mov   ipxSECB.SLt, cx    ; header length
  130.          xor   cx, cx             ; End_Of_Block identifyer
  131.  
  132. ; Set total length of packet
  133.  
  134.          mov   ax, ipxSECB.SLt
  135.          add   ax, ipxSECB.FLt
  136.          xchg  ah, al
  137.          mov   ipxHDR.PLt, ax
  138.  
  139. ; Then, call IPX send service...
  140.  
  141. CallIPX:
  142.          push  cx       ; save CX from modification
  143.          mov   bx, cs
  144.          mov   es, bx
  145.          mov   bx, 3
  146.          mov   si, OFFSET ipxSECB
  147.          call  ipxProc
  148.  
  149. ; Wait for complete of SEND function
  150.  
  151.          sti            ; enable interrupts
  152. PollInUse:
  153.          cmp   ipxSECB.InUse, 0
  154.          jnz   PollInUse
  155.  
  156.          pop   cx
  157.          and   cx, cx   ; have I some data for sending yet?
  158.          jz    SBExit
  159.          jmp   SetSAddr ; set address of next data fragment and
  160.                         ; try again...
  161. SBExit:
  162.          xor   ah, ah
  163.          mov   al, ipxSECB.RetCode  ; set return code
  164.  
  165.          pop   cx
  166.          ret
  167. SndBlk   ENDP
  168.  
  169. SetNtAddr PROC
  170.  
  171. ; Set network address in ECB
  172. ; ES:BX points to start of input segment.
  173.  
  174.           push cx
  175.           mov  ax, WORD PTR es:[bx]
  176.           mov  WORD PTR ipxSECB.PAddr, ax
  177.           mov  ax, WORD PTR es:[bx + 2]
  178.           mov  WORD PTR ipxSECB.PAddr + 2, ax
  179.           mov  ax, WORD PTR es:[bx + 4]
  180.           mov  WORD PTR ipxSECB.PAddr + 4, ax
  181.  
  182. ; Set network address in header
  183.  
  184.           mov  ax, WORD PTR es:[bx]
  185.           mov  WORD PTR ipxHDR.NdAddr, ax
  186.           mov  ax, WORD PTR es:[bx + 2]
  187.           mov  WORD PTR ipxHDR.NdAddr + 2, ax
  188.           mov  ax, WORD PTR es:[bx + 4]
  189.           mov  WORD PTR ipxHDR.NdAddr + 4, ax
  190.  
  191. ; Set destignated socket
  192.  
  193.           mov  ipxHDR.SkDest, MY_SOCKET
  194.  
  195. ; Set packet type
  196.  
  197.           cmp  LocalS, 0
  198.           je   InfoMsg
  199.           mov  ipxHDR.PType, 0  ; it's a control message
  200.           jmp  short TestBcs
  201. InfoMsg:
  202.           mov  ipxHDR.PType, 4  ; it's a information message
  203.  
  204. ; Test if it broadcasting message...
  205. TestBcs:
  206.  
  207.           xor  si, si
  208.           mov  cx, 6
  209. CmpCycl:
  210.           cmp  BYTE PTR es:[bx + si], 0ffh ; Node address
  211.           jne  SetExit                     ; == 0fffffffffffh
  212.           inc  si                          ; ???
  213.           loop CmpCycl
  214.  
  215.           call CancelECB                   ; cancel listen if so...
  216.  
  217. SetExit:
  218.           xor  ax, ax
  219.           pop  cx
  220.           ret
  221. SetNtAddr ENDP
  222.  
  223. NextBlk  PROC
  224.          push  cx
  225.          mov   ax, bx
  226.          mov   cx, 4
  227.          shr   ax, cl
  228.          mov   di, es
  229.          add   ax, di
  230.          mov   es, ax
  231.          and   bx, 000fh
  232.          pop   cx
  233.          ret
  234. NextBlk  ENDP
  235.  
  236.          END
  237.